/**
 * 
 */
package com.ws.framework.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.ws.framework.dao.RoleDao;
import com.ws.framework.model.Permission;

/**
 * <p>
 * </p>
 *
 * @author WSH
 */
@Repository
public class RoleDaoImpl implements RoleDao {

	private static final String selectPermissionByIdSql = "SELECT p.id, p.permission_name AS permissionName, p.create_time AS createTime, p.update_time AS updateTime FROM t_permission p, t_role_permission rp WHERE p.id = rp.permission_id AND rp.role_id = ?;";

	@Autowired
	JdbcTemplate jdbcTemplate;

	@Override
	public List<Permission> selectPermissionByRoleId(Long id) {
		return jdbcTemplate.query(selectPermissionByIdSql, new Object[]{id}, new BeanPropertyRowMapper<Permission>(Permission.class));
	}

}
